//
//  UsedCarDetailView.m
//  WWXELuShang
//
//  Created by 王涛 on 15/12/18.
//  Copyright © 2015年 lanou. All rights reserved.
//

#import "UsedCarDetailView.h"
#import "UsedCarDetail.h"
@implementation UsedCarDetailView
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        CGFloat width = self.frame.size.width;
        CGFloat height = self.frame.size.height;
        self.carnameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, 0, width - width / 37.5, height / 14))];
        self.carnameLabel.font = [UIFont boldSystemFontOfSize:15];
        [self addSubview:self.carnameLabel];
        
        UIImageView *imageView = [[UIImageView alloc] initWithFrame:(CGRectMake(0, height / 13, width, height - height / 14))];
        imageView.backgroundColor = [UIColor whiteColor];
        [self addSubview:imageView];
        self.registLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 10, width - width / 37.5, height / 13))];
        self.registLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.registLabel];
        
        self.priceLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 10 + height / 13, width  - width / 37.5, height / 13))];
        self.priceLabel.textColor = [UIColor redColor];
        self.priceLabel.font = [UIFont boldSystemFontOfSize:14];
        [self addSubview:self.priceLabel];
        
        self.cellAddressLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 10 + height / 13 * 2, width - width / 37.5, height / 13))];
        self.cellAddressLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.cellAddressLabel];
        
        UILabel *label1 = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 5 + height / 13 * 3, width - width / 37.5, height / 13))];
        label1.font = [UIFont boldSystemFontOfSize:15];
        label1.text = @"购车联系方式 :";
        [self addSubview:label1];
        
        self.cellnameLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 5 + height / 13 * 4, width - width / 37.5, height / 13))];
        self.cellnameLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.cellnameLabel];
        self.phoneLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 5 + height / 13 * 5, width - width / 37.5, height / 13))];
        self.phoneLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:self.phoneLabel];
        
        self.addressLabel = [[UILabel alloc] initWithFrame:(CGRectMake(width / 37.5, height / 5 + height / 13 * 6, width - width / 37.5, height / 13 * 2))];
        self.addressLabel.font = [UIFont systemFontOfSize:14];
        self.addressLabel.numberOfLines = 0;
        [self addSubview:self.addressLabel];
        

    }
    return self;
}
- (void)setUsedCarDetail:(UsedCarDetail *)usedCarDetail {
    if (_usedCarDetail != usedCarDetail) {
        _usedCarDetail = usedCarDetail;


        self.carnameLabel.text = usedCarDetail.name;
        NSArray *array = usedCarDetail.configinfo;
        NSString *string = @"  |  ";
        NSString *string1 = @"首次上牌 ";
        self.registLabel.text = [[[[[string1 stringByAppendingString:array[1][@"value"]] stringByAppendingString:string] stringByAppendingString:array[0][@"value"]] stringByAppendingString:string] stringByAppendingString:array[3][@"value"]];
        NSString *string2 = @"车主售价 : ";
        self.priceLabel.text = [string2 stringByAppendingString:usedCarDetail.price];
        self.cellAddressLabel.text = [[[[[[array[4][@"name"] stringByAppendingString:[NSString stringWithFormat:@" "]] stringByAppendingString:array[4][@"value"]] stringByAppendingString:string] stringByAppendingString:array[2][@"value"]]stringByAppendingString:string] stringByAppendingString:array[5][@"value"]];
        
        NSString *string3 = @"车主姓名 : ";
        self.cellnameLabel.text =[string3 stringByAppendingString:usedCarDetail.sellerinfo[@"name"]];
        
        NSString *string4 = @"手机号码 : ";
        self.phoneLabel.text = [string4 stringByAppendingString:usedCarDetail.sellerinfo[@"phone"]];
        
        NSString *string5 = @"详细地址 : ";
        self.addressLabel.text = [string5 stringByAppendingString:usedCarDetail.sellerinfo[@"address"]];
        
 
    }
}
@end
